<template>
	<view class="content">
		<mescroll-uni ref="mescrollRef" @init="mescrollInit" @up="upCallback" :up="upOption" :down="{use: false}">
			<view class="section-0">
				<view class="section-body">
					<view class="tops">
						<view class="items">
							<view class="item" @click="jump(age.id)" v-for="age in Odd" :key='age.id'>
								<image :src="age.file_path" mode="" class="img"></image>
								<view class="center">
									<view class="centerTop">
										{{age.name}}
										<image src="../../../../static/guo.png" mode="" class="imgs" >
										</image>
									</view>
									<view class="startTime">
										下批次开始时间：
										<view class="">
											{{age.start_time?age.start_time.substring(0,10):'~~'}}
										</view>
									</view>
								</view>
							</view>
						</view>
						<view class="children">
							<view class="item" @click="jump(item.id)" v-for=" item in even" :key='item.id'>
								<image :src="item.file_path" mode="" class="img"></image>
								<view class="center">
									<view class="centerTop">
										{{item.name}}
										<image src="../../../../static/guo.png" mode="" class="imgs" >
										</image>
									</view>
									<view class="startTime">
										下批次开始时间：
										<view class="">
											{{item.start_time?item.start_time.substring(0,10):'~~'}}
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="dist" v-if="false">
						<view class="distChild">
							<view class="agetwo">
								<view class="plans">
									待报计划个数
								</view>
								<view class="Number">
									66
								</view>
							</view>
							<view class="age">
								<view class="plans">
									计划总数
								</view>
								<view class="Number">
									66
								</view>
							</view>
						</view>
						<view class="distdag">
							<view>合同总数：110</view>
							<view>合同总金额：130万</view>
							<view>累计总支付金额：764万</view>
						</view>
						<view class="distlast">

						</view>
						<view class="form">
							<view class="form-item">
								<view class="label">项目名称</view>
								<view class="shape"></view>
								<view class="input">
									<u--input placeholderClass="input-placeholder" v-model="name" class="input-body">
									</u--input>
								</view>
							</view>
							<view class="actions">
								<view class="action" @click="handleResetForm()">
									<text>重</text>
									<text>置</text>
								</view>
								<view class="action search" @click="handleSearch()">
									<text>查</text>
									<text>询</text>
								</view>
							</view>
						</view>
						<view class="list">
							<view :class="`item ${item.show ? 'item__expand' : ''}`" v-for="(item, index) in list"
								:key="item.id + index">
								<view class="parent" @click="expandChange(item.id)">
									<view class="action">
										<view class="iconfont icon-xiangyou1"></view>
									</view>
									<view class="name">
										{{item.project_name}}
									</view>
								</view>
								<view class="child" v-if="item.show">
									<view class="child-item" @click="go(item2)" v-for="(item2, idx) in item.children"
										:key="item2.id + idx">
										<view class="top">
											<view class="name">
												{{item2.project_name}}
											</view>
											<view class="action">
												待报计划
											</view>
										</view>
										<view class="buttom">
											11111
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>

			</view>
		</mescroll-uni>
	</view>
</template>

<script>
	import {
		procurement
	} from '@/api/procurement.js'
	export default {

		data() {
			return {
				//定义不同卡片的照片
				listTop: [],
				Odd:[],
				even:[],
				upOption: {
					textNoMore: '-- 没有更多了 --'
				},
				mescroll: null, // mescroll实例对象 (此行可删,mixins已默认)
				list: [{
						id: 1,
						project_name: '11111',
						children: [{
							id: 3,
							project_name: '2222222'
						}, {
							id: 9,
							project_name: '023898'
						}, {
							id: 10,
							project_name: '72389479'
						}]
					},
					{
						id: 2,
						project_name: '333333',
						children: [{
							id: 4,
							project_name: '444444'
						}]
					},
					{
						id: 5,
						project_name: '55555',
						children: [{
							id: 6,
							project_name: '66666'
						}]
					},
					{
						id: 7,
						project_name: '7777',
						children: [{
							id: 8,
							project_name: '8888'
						}]
					}
				],
				name: ''
			}
		},

		methods: {
		   async onLoad(){
				const {
					data
				} = await procurement()
				this.listTop=data.data.data
				let even=[]
				let Odd=[]
				this.listTop.forEach(item=>{
					if(item.id==1||item.id==2){
						Odd.push(item)
					}else{
						even.push(item)
					}
				})
				this.Odd=Odd
				this.even=even
			},
			jump(id) {
				uni.navigateTo({
					url: '/pages/work/manager/procurement/Materialdetails?params= ' + JSON.stringify(id)
				})
			},
			go(id){
				uni.navigateTo({
					url: '/pages/statistics/material/Biddingbatch/Batchdetails?params= ' + JSON.stringify(id)
				})
			},
			handleResetForm() {
				this.name = ''
				// this.listGroupApi()
			},
			handleSearch() {
				// this.listGroupApi()
			},
			mescrollInit(mescroll) {
				this.mescroll = mescroll;
			},
			async expandChange(id) {
				const dep = JSON.parse(JSON.stringify(this.list));
				let _idx = undefined;
				dep.forEach((item, idx) => {
					if (item.id === id) {
						if (dep[idx].show) {
							dep[idx].show = false;
						} else {
							dep[idx].show = true;
							_idx = idx;
							if (!dep[idx].children) {
								dep[idx].children = [];
							}
						}
					}
				})
				if (_idx !== undefined && dep[_idx].children && dep[_idx].children.length === 0) {
					uni.showLoading({
						title: '加载中...'
					})
					const {
						data
					} = await listGroupApi({});
					uni.hideLoading();
					dep[_idx].children = data.data;
				}
				this.list = dep;
			},
			async upCallback(page) {
				this.mescroll.endErr()
				// const {
				// 	data
				// } = await listApi({
				// 	project_id: this.curProject.id,
				// 	page: page.num,
				// 	pageSize: this.pageSize,
				// });
				// if (data.code === 1 || data.code === 200) {
				// 	// 接口返回的当前页数据列表 (数组)
				// 	let curPageData = data.data.data;
				// 	// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
				// 	let curPageLen = curPageData.length;
				// 	// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
				// 	let totalPage = data.data.data.last_page;
				// 	//设置列表数据
				// 	if (page.num == 1) this.list = []; //如果是第一页需手动置空列表
				// 	this.list = this.list.concat(curPageData); //追加新数据
				// 	// this.list=curPageData
				// 	// 请求成功,隐藏加载状态
				// 	this.mescroll.endByPage(curPageLen, totalPage);
				// 	setTimeout(() => {
				// 		this.mescroll.endSuccess(curPageLen);
				// 	}, 20);
				// 	this.mescroll.endErr()
				// } else {
				// 	//  请求失败,隐藏加载状态
				// 	this.mescroll.endErr()
				// }
			},

		}
	}
</script>

<style lang="scss" scoped>
	.section-0 {
		width: 100%;
		position: relative;
		z-index: 10;
		background: #2e5efe;

		.section-body {
			width: 100%;
			height: 100%;
			border-top-left-radius: 50rpx;
			border-top-right-radius: 50rpx;
			background-color: #fff;
			overflow: hidden;

			.tops {
				width: 95%;
				height: 320rpx;
				background-color: #fff;
				border-radius: 50rpx;
				margin: 40rpx auto;
				box-shadow: 0 0 28rpx 14rpx rgba(#bcbcb5, 0.3);
				display: flex;
				 .items{
					 width: 45%;
					 margin-left: 25rpx;
				 }
				 .children{
					 width: 45%;
					  margin-left: 20rpx;
				 }
				.item {
					width: 100%;
					height: 130rpx;
					display: flex;
					background-color: #0837b7;
					margin-top: 20rpx;
					border-radius: 20rpx;
					color: #fff;

					.img {
						width: 50rpx;
						height: 60rpx;
						margin: auto 10rpx;
					}

					.center {
						margin-top: 10rpx;
					}

					.centerTop {
						font-weight: 700;
					}

					.startTime {
						font-size: 10rpx;
						margin-top: 10rpx;
					}

					.imgs {
						width: 15rpx;
						height: 25rpx;
						margin-left: 100rpx;
					}
				}
			}

			.dist {
				width: 100%;
				height: 100%;
				border-top-left-radius: 50rpx;
				border-top-right-radius: 50rpx;
				background-color: #fff;
				box-shadow: 0 0 28rpx 14rpx rgba(#bcbcb5, 0.3);
				padding-top: 40rpx;

				.distChild {
					display: flex;
					margin: auto;
					justify-content: center;
					align-items: center;
					text-align: center;
					margin-bottom: 40rpx;

					.plans {
						font-size: 10rpx;
					}

					.Number {
						font-size: 80rpx;
						font-weight: 700;
						color: #ffdc00;
					}

					.agetwo {
						margin-right: 120rpx;
					}

					.age {
						border-left: 4rpx dashed #929292;
						padding-left: 120rpx;
					}
				}

				.distdag {
					display: flex;
					font-size: 10rpx;
					justify-content: space-around;
					margin-bottom: 30rpx;
				}

				.distlast {
					width: 70%;
					height: 3rpx;
					border-top: 4rpx dashed #929292;
					margin: auto;
				}

				.tab {
					width: 100%;
					height: 80rpx;
					@include clear();
					background-color: #1534ce;

					.item {
						width: 33.33%;
						float: left;
						height: 80rpx;
						background-color: #1534ce;
						position: relative;

						.label {
							height: 80rpx;
							line-height: 80rpx;
							position: relative;
							z-index: 10;
							box-sizing: border-box;
							text-align: center;
							width: 100%;
							font-size: 26rpx;
							font-weight: normal;
							font-stretch: normal;
							letter-spacing: 0rpx;
							color: #ffffff;
						}

						.shape {
							z-index: 1;
							width: 50rpx;
							height: 50rpx;
							position: absolute;
							bottom: 0;
							left: -50rpx;
							background: #000;
							display: none;
							background-color: #fff;
							overflow: hidden;

							.shape-body {
								width: 50rpx;
								height: 50rpx;
								background-color: #1534ce;
								border-bottom-right-radius: 40rpx;
							}
						}

						.shape-mirrow {
							z-index: 1;
							left: 0;
							display: none;

							.shape-body {
								border-bottom-right-radius: 0rpx;
								border-bottom-left-radius: 40rpx;
							}
						}
					}

					.item__active {
						border-top-left-radius: 40rpx;
						border-top-right-radius: 40rpx;
						background-color: #fff;

						.label {
							color: #46464a;
						}

						.shape {
							display: block;
						}

						.shape-mirrow {
							display: none;
						}
					}

					.item__active_next {
						border-bottom-right-radius: 50rpx;

						.shape {
							display: none;
						}

						.shape-mirrow {
							display: block;
						}
					}

				}

				.list {
					width: 670rpx;
					box-sizing: border-box;
					margin-left: 40rpx;
					border-top: 2rpx solid #d8e4f2;

					.item {
						width: 100%;
						border-bottom: solid 2rpx #f2f2f0;

						.parent {
							width: 100%;
							@include clear();

							.name {
								width: calc(100% - 50rpx);
								line-height: 30rpx;
								padding: 26rpx 0;
								font-size: 35rpx;
								font-weight: normal;
								font-stretch: normal;

								letter-spacing: 2rpx;
								color: #3b3c40;
								float: left;
								word-break: break-all;
							}

							.count {
								float: right;
								min-width: 46rpx;
								height: 46rpx;
								margin-top: 18rpx;
								border-radius: 28rpx;
								line-height: 46rpx;
								text-align: center;
								font-size: 35rpx;
								font-weight: bold;
								color: #395cf5;
								background: #ffde00;

								// margin-right: 40rpx;
								text {
									font-size: 16rpx;
								}
							}

							.action {
								float: right;
								width: 32rpx;
								margin-right: 18rpx;
								height: 100%;
								line-height: 82rpx;
								text-align: center;
								color: #3b3c40;

								.iconfont {
									font-size: 32rpx;
									transition: 0.2s ease;
									transform: rotate(90deg);
								}


							}
						}

						.child {
							width: 750rpx;
							margin-left: - 40rpx;
							background: #f2f2fa;
							padding-right: 30rpx;

							.child-item {
								// width: 620rpx;
								width: 670rpx;
								margin-left: 40rpx;
								border-bottom: 2rpx solid #e3e8f5;

								&:last-child {
									border-bottom: none
								}

								.top {
									width: 100%;
									height: 50rpx;
									padding-top: 30rpx;

									.name {

										float: left;
										// width: calc(100% - 40rpx);
										// height: 40rpx;
										// line-height: 40rpx;
										color: #3b3c40;
										font-size: 35rpx;
										// padding: 30rpx 0;
										text-overflow: ellipsis;
										overflow: hidden;
										white-space: nowrap;
									}

									.action {
										float: right;
										width: 110rpx;
										height: 35rpx;
										border: 1rpx solid #0535D6;
										border-radius: 30rpx;
										text-align: center;
										line-height: 35rpx;
										font-size: 10rpx;
										color: #0535D6;

										.iconfont {
											// font-size: 32rpx;
											// color: #7f98ae;
										}
									}
								}

								.buttom {
									display: block;
									padding-bottom: 20rpx;
								}
							}
						}
					}

					.item__expand {
						.parent {
							.action {
								.iconfont {
									transform: rotate(-90deg);
								}
							}
						}

						.child {
							box-shadow: 0rpx 10rpx 10rpx 0rpx rgba(0, 0, 0, 0.03) inset;
						}
					}
				}

				.actions {
					width: 100%;
					height: 50rpx;
					margin-top: 29rpx;
					padding-bottom: 40rpx;
					display: flex;
					justify-content: space-between;

					.action {
						width: 288rpx;
						height: 48rpx;
						background-color: #395cf5;
						border-radius: 20rpx;
						text-align: center;
						line-height: 48rpx;
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						line-height: 48rpx;
						color: #ffffff;

						text {
							&:first-child {
								margin-right: 20rpx;
							}
						}
					}

					.search {
						background-color: #1534ce;
					}
				}

				.form {
					width: 100%;
					padding: 0 75rpx;
					padding-top: 30rpx;
					box-sizing: border-box;

					.form-item {
						width: 600rpx;
						height: 48rpx;
						border-radius: 20rpx;
						border: solid 2rpx #1534ce;
						margin: 0 auto;
						margin-bottom: 25rpx;

						&:last-child {
							margin-bottom: 34rpx;
						}

						@include clear();

						.label {
							float: left;
							width: 134rpx;
							height: 48rpx;
							text-align: center;
							line-height: 44rpx;
							font-size: 26rpx;
							font-weight: normal;
							font-stretch: normal;
							letter-spacing: 0rpx;
							color: #1534ce;
						}

						.shape {
							width: 3rpx;
							height: 32rpx;
							background-color: #7f98ae;
							float: left;
							margin-top: 8rpx;
						}

						.input {
							float: left;
							width: calc(100% - 134rpx - 3rpx);

							.input-body {
								box-sizing: border-box;
								width: 100%;
								height: 44rpx;
								padding: 0 !important;
								border: none;
								padding-left: 30rpx !important;
								padding-right: 30rpx !important;
								font-size: 26rpx;
								font-weight: normal;
								font-stretch: normal;
								letter-spacing: 0rpx;
								color: rgba(0, 0, 0, 0.7);
							}

							.input-placeholder {
								font-size: 26rpx;
								font-weight: normal;
								font-stretch: normal;
								letter-spacing: 0rpx;
								color: rgba(0, 0, 0, 0.5);
							}
						}
					}
				}

				.total {
					box-sizing: border-box;
					padding: 0 70rpx;
					height: 80rpx;
					line-height: 70rpx;
					font-size: 22rpx;
					font-weight: normal;
					font-stretch: normal;
					line-height: 80rpx;
					letter-spacing: 0rpx;
					color: #3b3c40;
				}

				.charts {
					width: 100%;
					box-sizing: border-box;
					height: 315rpx;
					padding: 0 70rpx;
					padding-left: calc(70rpx - 15px);
					margin-bottom: 30rpx;

					#echarts {
						width: 100%;
						height: 100%;
					}
				}

				.top-tab {
					width: 670rpx;
					margin-left: 40rpx;
					height: 52rpx;
					line-height: 52rpx;
					display: flex;
					justify-content: space-between;
					box-sizing: border-box;
					padding: 0 30rpx;
					margin-top: 15rpx;
					border-bottom: solid 3rpx #f2f2f0;

					.item {
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						line-height: 50rpx;
						letter-spacing: 0rpx;
						color: #d8d8d5;
						position: relative;

						.shape {
							opacity: 0;
							transform: translateY(6rpx);
							position: absolute;
							bottom: -6rpx;
							width: 100%;
							height: 8rpx;
							background-color: #1534ce;
							border-radius: 8rpx;
							transition: 0.3s ease;
						}
					}

					.item__active {
						color: #3b3c40;

						.shape {
							opacity: 1;
							transform: translateY(0rpx);
						}
					}
				}
			}
		}

	}
</style>
